package com.mnsq.user.controller;

import com.mnsq.common.bean.annotation.UserInfoRequired;
import com.mnsq.common.bean.conf.ThreadLocalInfo;
import com.mnsq.common.bean.dto.LoginInfo;
import com.mnsq.user.bean.condition.UserOperationCondition;
import com.mnsq.user.service.UserOperationService;
import matrix.module.common.bean.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @date 2019/4/21 0021
 */
@Api("用户个人操作相关接口")
@RestController
@RequestMapping("/api/user")
public class UserOperationController {

    @Autowired
    private UserOperationService userOperationService;

    @ApiOperation(value = "用户建议提交接口", notes = "用户建议提交接口")
    @UserInfoRequired(required = true)
    @PostMapping("suggest")
    public Result suggest(@RequestBody UserOperationCondition userOperationCondition) {
        return userOperationService.save(userOperationCondition);
    }

    @ApiOperation(value = "用户数据查询接口", notes = "用户相关数量数据")
    @UserInfoRequired(required = true)
    @PostMapping("counts/info")
    public Result userCounts() {
        LoginInfo loginInfo = ThreadLocalInfo.LOGIN_INFO.get();
        return userOperationService.userCounts(loginInfo.getUserId());
    }
}
